#include <stdio.h>
#include "../../utils/utils.h"
#include "ex4.h"

#define MAX_LENGTH 1000

/**
* 在 s1中 删除 s2包含的 char
* @param s1
* @param s2
*/
void squeeze(char s1[], char s2[]);
int squeezeTest() {

    char line[MAX_LENGTH];
    char line2[MAX_LENGTH];
    int l = getLine(line, MAX_LENGTH);
    int l2 = getLine(line2, MAX_LENGTH);
    if (l > 0 && l2 > 0) {
        squeeze(line, line2);
        printf("result %s\n", line);
    } else {
        printf("nothing\n");
    }
    return 0;
}

void squeeze(char s1[], char s2[]) {
    printf("s1: %s, s2: %s\n", s1, s2);
    int i = 0, j = 0;
    char c;
    while ((c = s1[i++]) != '\0') {
        printf("contain? %d\n", contain(c, s2));
        if (!contain(c, s2)) {
            s1[j++] = c;
        }
    };
    s1[j] = '\0';
}

int contain(char c, char s2[]) {
    printf("c: %c, s2: %s", c, s2);
    int i = 0;
    char c2;
    while ((c2 = s2[i++]) != '\0') {
        if (c2 == c) {
            return 1;
        }
    }

    return 0;

}
